<?php

namespace api\controllers;

use bc\controller\ApiController;

class AppversionController extends ApiController
{
	
	protected $andoridMarkets = [
			'B1' => 
				['name' => '',  'url' => 'http://www.zhishimama.com/'],
	];
	
	
	public function actionIosVer()
	{
		$need_update = '0';
		$force_update = '0';
		
		$version = trim($_REQUEST['version']);
		
		switch ($version)
		{
			case '3.0':
				$need_update  = '0';
				$force_update = '0';
				break;
			case '3.1':
				$need_update  = '1';
				$force_update = '0';
				break;
			case '4.0':
				$need_update  = '1';
				$force_update = '1';
				break;
			default:
				$need_update  = '0';
				$force_update = '0';
				break;
		}
		
		
		return [ 
				'title'	  		=> '芝士妈妈-升级提示',
				'content' 		=> '芝士妈妈升级至版本3.0',
				'url'     		=> 'itms-apps://itunes.apple.com/app/id1110610776',
				'need_update' 	=> $need_update,
				'force_update'	=> $force_update
		];
	}
	
	public function actionAndroidVer()
	{
		$need_update = '0';
		$force_update = '0';
	
		$version = trim($_REQUEST['version']);
		$market = trim($_REQUEST['market'])?$_REQUEST['market']:'B1';
	
		switch ($version)
		{
			case '3.0':
				$need_update  = '0';
				$force_update = '0';
				break;
			case '3.1':
				$need_update  = '1';
				$force_update = '0';
				break;
			case '4.0':
				$need_update  = '1';
				$force_update = '1';
				break;
			default:
				$need_update  = '0';
				$force_update = '0';
				break;
		}
	
	
		return [
				'title'	  		=> '芝士妈妈-升级提示',
				'content' 		=> '芝士妈妈升级至版本3.0',
				'url'     		=> $this->andoridMarkets[$market]['url'],
				'need_update' 	=> $need_update,
				'force_update'	=> $force_update
		];
	}
}

